﻿using Magicodes.ExporterAndImporter.Core.Extension;
using NP.BPMReportPlatform.DBHelper;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace NP.BPMReportPlatform.DBHelper
{
    /// <summary>
    /// 通用扩展方法
    /// </summary>
    public class CommonSqlFuncExtension
    {
        public CommonSqlFuncExtension()
        {
            //Console.WriteLine("CommonApprovalSqlFuncExtension 构造了");
        }

        public List<SqlFuncExternal> ExpandSqlFuncs = new List<SqlFuncExternal>()
        {
            new SqlFuncExternal()
            {
                UniqueMethodName = "CustomFieldSelect",
                MethodValue = (expInfo, dbType, expContext) =>
                {
                    if (dbType == DbType.MySql)
                    {
                        var sql = @" {0} ";

                        return string.Format(sql, expInfo.Args[0].MemberValue);
                    }
                    else
                    {
                        throw new Exception("未实现");
                    }
                }
            }
        };

        public static string CustomFieldSelect(string customStr)
            => throw new NotSupportedException("Can only be used in expressions");
    }
}
